package qldc.pm.qlktcsdldc.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import qldc.pm.qlktcsdldc.model.TruongCongDan;
import qldc.pm.qlktcsdldc.model.TruongCongDanModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the TruongCongDan service. Represents a row in the &quot;QLKT_TruongCongDan&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link qldc.pm.qlktcsdldc.model.TruongCongDanModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link TruongCongDanImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see TruongCongDanImpl
 * @see qldc.pm.qlktcsdldc.model.TruongCongDan
 * @see qldc.pm.qlktcsdldc.model.TruongCongDanModel
 * @generated
 */
public class TruongCongDanModelImpl extends BaseModelImpl<TruongCongDan>
    implements TruongCongDanModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a truong cong dan model instance should use the {@link qldc.pm.qlktcsdldc.model.TruongCongDan} interface instead.
     */
    public static final String TABLE_NAME = "QLKT_TruongCongDan";
    public static final Object[][] TABLE_COLUMNS = {
            { "IDDMDC_TruongCongDan", Types.BIGINT },
            { "groupId", Types.BIGINT },
            { "companyId", Types.BIGINT },
            { "userId", Types.BIGINT },
            { "userName", Types.VARCHAR },
            { "createDate", Types.TIMESTAMP },
            { "modifiedDate", Types.TIMESTAMP },
            { "TenTruongCongDan", Types.VARCHAR },
            { "GiaiThich", Types.VARCHAR }
        };
    public static final String TABLE_SQL_CREATE = "create table QLKT_TruongCongDan (IDDMDC_TruongCongDan LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,TenTruongCongDan VARCHAR(75) null,GiaiThich VARCHAR(75) null)";
    public static final String TABLE_SQL_DROP = "drop table QLKT_TruongCongDan";
    public static final String ORDER_BY_JPQL = " ORDER BY truongCongDan.IDDMDC_TruongCongDan ASC";
    public static final String ORDER_BY_SQL = " ORDER BY QLKT_TruongCongDan.IDDMDC_TruongCongDan ASC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.qldc.pm.qlktcsdldc.model.TruongCongDan"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.qldc.pm.qlktcsdldc.model.TruongCongDan"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.qldc.pm.qlktcsdldc.model.TruongCongDan"),
            true);
    public static long IDDMDC_TRUONGCONGDAN_COLUMN_BITMASK = 1L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.qldc.pm.qlktcsdldc.model.TruongCongDan"));
    private static ClassLoader _classLoader = TruongCongDan.class.getClassLoader();
    private static Class<?>[] _escapedModelInterfaces = new Class[] {
            TruongCongDan.class
        };
    private long _IDDMDC_TruongCongDan;
    private long _originalIDDMDC_TruongCongDan;
    private boolean _setOriginalIDDMDC_TruongCongDan;
    private long _groupId;
    private long _companyId;
    private long _userId;
    private String _userUuid;
    private String _userName;
    private Date _createDate;
    private Date _modifiedDate;
    private String _TenTruongCongDan;
    private String _GiaiThich;
    private long _columnBitmask;
    private TruongCongDan _escapedModel;

    public TruongCongDanModelImpl() {
    }

    @Override
    public long getPrimaryKey() {
        return _IDDMDC_TruongCongDan;
    }

    @Override
    public void setPrimaryKey(long primaryKey) {
        setIDDMDC_TruongCongDan(primaryKey);
    }

    @Override
    public Serializable getPrimaryKeyObj() {
        return _IDDMDC_TruongCongDan;
    }

    @Override
    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    @Override
    public Class<?> getModelClass() {
        return TruongCongDan.class;
    }

    @Override
    public String getModelClassName() {
        return TruongCongDan.class.getName();
    }

    @Override
    public Map<String, Object> getModelAttributes() {
        Map<String, Object> attributes = new HashMap<String, Object>();

        attributes.put("IDDMDC_TruongCongDan", getIDDMDC_TruongCongDan());
        attributes.put("groupId", getGroupId());
        attributes.put("companyId", getCompanyId());
        attributes.put("userId", getUserId());
        attributes.put("userName", getUserName());
        attributes.put("createDate", getCreateDate());
        attributes.put("modifiedDate", getModifiedDate());
        attributes.put("TenTruongCongDan", getTenTruongCongDan());
        attributes.put("GiaiThich", getGiaiThich());

        return attributes;
    }

    @Override
    public void setModelAttributes(Map<String, Object> attributes) {
        Long IDDMDC_TruongCongDan = (Long) attributes.get(
                "IDDMDC_TruongCongDan");

        if (IDDMDC_TruongCongDan != null) {
            setIDDMDC_TruongCongDan(IDDMDC_TruongCongDan);
        }

        Long groupId = (Long) attributes.get("groupId");

        if (groupId != null) {
            setGroupId(groupId);
        }

        Long companyId = (Long) attributes.get("companyId");

        if (companyId != null) {
            setCompanyId(companyId);
        }

        Long userId = (Long) attributes.get("userId");

        if (userId != null) {
            setUserId(userId);
        }

        String userName = (String) attributes.get("userName");

        if (userName != null) {
            setUserName(userName);
        }

        Date createDate = (Date) attributes.get("createDate");

        if (createDate != null) {
            setCreateDate(createDate);
        }

        Date modifiedDate = (Date) attributes.get("modifiedDate");

        if (modifiedDate != null) {
            setModifiedDate(modifiedDate);
        }

        String TenTruongCongDan = (String) attributes.get("TenTruongCongDan");

        if (TenTruongCongDan != null) {
            setTenTruongCongDan(TenTruongCongDan);
        }

        String GiaiThich = (String) attributes.get("GiaiThich");

        if (GiaiThich != null) {
            setGiaiThich(GiaiThich);
        }
    }

    @Override
    public long getIDDMDC_TruongCongDan() {
        return _IDDMDC_TruongCongDan;
    }

    @Override
    public void setIDDMDC_TruongCongDan(long IDDMDC_TruongCongDan) {
        _columnBitmask = -1L;

        if (!_setOriginalIDDMDC_TruongCongDan) {
            _setOriginalIDDMDC_TruongCongDan = true;

            _originalIDDMDC_TruongCongDan = _IDDMDC_TruongCongDan;
        }

        _IDDMDC_TruongCongDan = IDDMDC_TruongCongDan;
    }

    public long getOriginalIDDMDC_TruongCongDan() {
        return _originalIDDMDC_TruongCongDan;
    }

    @Override
    public long getGroupId() {
        return _groupId;
    }

    @Override
    public void setGroupId(long groupId) {
        _groupId = groupId;
    }

    @Override
    public long getCompanyId() {
        return _companyId;
    }

    @Override
    public void setCompanyId(long companyId) {
        _companyId = companyId;
    }

    @Override
    public long getUserId() {
        return _userId;
    }

    @Override
    public void setUserId(long userId) {
        _userId = userId;
    }

    @Override
    public String getUserUuid() throws SystemException {
        return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
    }

    @Override
    public void setUserUuid(String userUuid) {
        _userUuid = userUuid;
    }

    @Override
    public String getUserName() {
        if (_userName == null) {
            return StringPool.BLANK;
        } else {
            return _userName;
        }
    }

    @Override
    public void setUserName(String userName) {
        _userName = userName;
    }

    @Override
    public Date getCreateDate() {
        return _createDate;
    }

    @Override
    public void setCreateDate(Date createDate) {
        _createDate = createDate;
    }

    @Override
    public Date getModifiedDate() {
        return _modifiedDate;
    }

    @Override
    public void setModifiedDate(Date modifiedDate) {
        _modifiedDate = modifiedDate;
    }

    @Override
    public String getTenTruongCongDan() {
        if (_TenTruongCongDan == null) {
            return StringPool.BLANK;
        } else {
            return _TenTruongCongDan;
        }
    }

    @Override
    public void setTenTruongCongDan(String TenTruongCongDan) {
        _TenTruongCongDan = TenTruongCongDan;
    }

    @Override
    public String getGiaiThich() {
        if (_GiaiThich == null) {
            return StringPool.BLANK;
        } else {
            return _GiaiThich;
        }
    }

    @Override
    public void setGiaiThich(String GiaiThich) {
        _GiaiThich = GiaiThich;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
            TruongCongDan.class.getName(), getPrimaryKey());
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        ExpandoBridge expandoBridge = getExpandoBridge();

        expandoBridge.setAttributes(serviceContext);
    }

    @Override
    public TruongCongDan toEscapedModel() {
        if (_escapedModel == null) {
            _escapedModel = (TruongCongDan) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
        }

        return _escapedModel;
    }

    @Override
    public Object clone() {
        TruongCongDanImpl truongCongDanImpl = new TruongCongDanImpl();

        truongCongDanImpl.setIDDMDC_TruongCongDan(getIDDMDC_TruongCongDan());
        truongCongDanImpl.setGroupId(getGroupId());
        truongCongDanImpl.setCompanyId(getCompanyId());
        truongCongDanImpl.setUserId(getUserId());
        truongCongDanImpl.setUserName(getUserName());
        truongCongDanImpl.setCreateDate(getCreateDate());
        truongCongDanImpl.setModifiedDate(getModifiedDate());
        truongCongDanImpl.setTenTruongCongDan(getTenTruongCongDan());
        truongCongDanImpl.setGiaiThich(getGiaiThich());

        truongCongDanImpl.resetOriginalValues();

        return truongCongDanImpl;
    }

    @Override
    public int compareTo(TruongCongDan truongCongDan) {
        int value = 0;

        if (getIDDMDC_TruongCongDan() < truongCongDan.getIDDMDC_TruongCongDan()) {
            value = -1;
        } else if (getIDDMDC_TruongCongDan() > truongCongDan.getIDDMDC_TruongCongDan()) {
            value = 1;
        } else {
            value = 0;
        }

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (!(obj instanceof TruongCongDan)) {
            return false;
        }

        TruongCongDan truongCongDan = (TruongCongDan) obj;

        long primaryKey = truongCongDan.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        TruongCongDanModelImpl truongCongDanModelImpl = this;

        truongCongDanModelImpl._originalIDDMDC_TruongCongDan = truongCongDanModelImpl._IDDMDC_TruongCongDan;

        truongCongDanModelImpl._setOriginalIDDMDC_TruongCongDan = false;

        truongCongDanModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<TruongCongDan> toCacheModel() {
        TruongCongDanCacheModel truongCongDanCacheModel = new TruongCongDanCacheModel();

        truongCongDanCacheModel.IDDMDC_TruongCongDan = getIDDMDC_TruongCongDan();

        truongCongDanCacheModel.groupId = getGroupId();

        truongCongDanCacheModel.companyId = getCompanyId();

        truongCongDanCacheModel.userId = getUserId();

        truongCongDanCacheModel.userName = getUserName();

        String userName = truongCongDanCacheModel.userName;

        if ((userName != null) && (userName.length() == 0)) {
            truongCongDanCacheModel.userName = null;
        }

        Date createDate = getCreateDate();

        if (createDate != null) {
            truongCongDanCacheModel.createDate = createDate.getTime();
        } else {
            truongCongDanCacheModel.createDate = Long.MIN_VALUE;
        }

        Date modifiedDate = getModifiedDate();

        if (modifiedDate != null) {
            truongCongDanCacheModel.modifiedDate = modifiedDate.getTime();
        } else {
            truongCongDanCacheModel.modifiedDate = Long.MIN_VALUE;
        }

        truongCongDanCacheModel.TenTruongCongDan = getTenTruongCongDan();

        String TenTruongCongDan = truongCongDanCacheModel.TenTruongCongDan;

        if ((TenTruongCongDan != null) && (TenTruongCongDan.length() == 0)) {
            truongCongDanCacheModel.TenTruongCongDan = null;
        }

        truongCongDanCacheModel.GiaiThich = getGiaiThich();

        String GiaiThich = truongCongDanCacheModel.GiaiThich;

        if ((GiaiThich != null) && (GiaiThich.length() == 0)) {
            truongCongDanCacheModel.GiaiThich = null;
        }

        return truongCongDanCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(19);

        sb.append("{IDDMDC_TruongCongDan=");
        sb.append(getIDDMDC_TruongCongDan());
        sb.append(", groupId=");
        sb.append(getGroupId());
        sb.append(", companyId=");
        sb.append(getCompanyId());
        sb.append(", userId=");
        sb.append(getUserId());
        sb.append(", userName=");
        sb.append(getUserName());
        sb.append(", createDate=");
        sb.append(getCreateDate());
        sb.append(", modifiedDate=");
        sb.append(getModifiedDate());
        sb.append(", TenTruongCongDan=");
        sb.append(getTenTruongCongDan());
        sb.append(", GiaiThich=");
        sb.append(getGiaiThich());
        sb.append("}");

        return sb.toString();
    }

    @Override
    public String toXmlString() {
        StringBundler sb = new StringBundler(31);

        sb.append("<model><model-name>");
        sb.append("qldc.pm.qlktcsdldc.model.TruongCongDan");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>IDDMDC_TruongCongDan</column-name><column-value><![CDATA[");
        sb.append(getIDDMDC_TruongCongDan());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>groupId</column-name><column-value><![CDATA[");
        sb.append(getGroupId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>companyId</column-name><column-value><![CDATA[");
        sb.append(getCompanyId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userId</column-name><column-value><![CDATA[");
        sb.append(getUserId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userName</column-name><column-value><![CDATA[");
        sb.append(getUserName());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>createDate</column-name><column-value><![CDATA[");
        sb.append(getCreateDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
        sb.append(getModifiedDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>TenTruongCongDan</column-name><column-value><![CDATA[");
        sb.append(getTenTruongCongDan());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>GiaiThich</column-name><column-value><![CDATA[");
        sb.append(getGiaiThich());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
